<!--
 * @Description: 
 * @Date: 2025-07-31 09:50:30
 * @LastEditTime: 2025-09-05 13:48:27
-->
<template>

  <img src="../assets/img/manA.png" alt="" width="150" height="150" class="avatar">
  <div v-if="issubmit != 0" class="w-100%">
    <div v-for="(item, index) in records" :key="index"
      class="bg-#fff w-95% mx-auto border-rd-20px mt-30px flex flex-col gap-10px p-20px items-start">
      <div class="flex items-center">
        <span class="text-16px font-bold">当前状态：</span><span> <van-tag size="medium" type="success">预约成功</van-tag></span>
      </div>
      <div class="flex items-center">
        <span class="text-16px font-bold">姓名：</span><span>{{ item.real_name }}</span>
      </div>
      <div class="flex items-center">
        <span class="text-16px font-bold">预约医院：</span><span>{{ item.hospital_name }}</span>
      </div>
      <div class="flex items-center">
        <span class="text-16px font-bold">预约套餐：</span><span>{{ item.amount }}</span>
      </div>
      <div class="flex items-center">
        <span class="text-16px font-bold">自选时间：</span><span>{{ item.create_time }}</span>
      </div>
      <div class="text-red">备注：具体体检时间另行通知！</div>
    </div>
  </div>

  <div>
    <van-button type="primary" @click="logout" class="logout">退出登录</van-button>
  </div>
  <van-tabbar v-model="active">
    <van-tabbar-item icon="home-o" @click="goToPage('main')">首页</van-tabbar-item>
    <van-tabbar-item icon="setting-o" @click="goToPage('settings')">我的</van-tabbar-item>
  </van-tabbar>
</template>

<script setup>
import { useRouter, useRoute } from "vue-router";
import { ref, onMounted } from "vue";
import store from "@/store";
import { Toast } from "vant";
import { reservationsByUserld } from "../api/user"
const router = useRouter();
const route = useRoute()
const issubmit = route.query.issubmit
const records = ref()
let logout = async () => {
  // await store.dispatch("user/logout");
  // Toast.success("退出登录成功");
  // router.push({
  //   path: '/login',
  //   query: {
  //     redirect: router.fullPath,
  //   },
  // })
};
onMounted(() => {
  if (issubmit != 0) {
    reservationsByUserld({ userId: Number(store.getters.userid) }).then(res => {
      if (res.data.code == 200) {
        records.value = res.data.data
      }
    })
  }

})

const active = ref(1);
const goToPage = (name) => {
  switch (name) {
    case "main":
      router.push("/main");
      break;
    case "settings":
      router.push(`/settings`);
      break;
  }
};
</script>

<style scoped>
.avatar {
  border: 1px solid blue;
  margin-top: 20px;
  border-radius: 50%;
}

.name {
  margin-top: 20px;
  font-weight: bold;
}

.logout {
  margin-top: 20px;

}
</style>
